package org.example.chat.websocket.messagehandler;

import io.netty.channel.Channel;
import org.example.chat.websocket.entity.MessagePack;

/**
 * 消息处理上下文对象
 * @author cheval
 */
public class MessageHandlerContext {

    /** 消息处理器 */
    public MessageHandler messageHandler;
    /** 接收到的消息 */
    public MessagePack messagePack;
    /** 接收消息的channel */
    public Channel channel;

    /**
     * @param messageHandler 抽象消息处理器
     * @param messagePack   消息包
     * @param channel       发送消息包的channel
     */
    public MessageHandlerContext(MessageHandler messageHandler, MessagePack messagePack, Channel channel) {
        this.messageHandler = messageHandler;
        this.messagePack = messagePack;
        this.channel = channel;
    }


    public void handler() {
        messageHandler.handler(this);
    }
}
